package com.liu.behaviortracker;

import java.io.File;

import com.liu.hooks.AbstractHook;
import com.liu.util.TrackerLoger;

import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;

public class BehaviorTracker implements IXposedHookLoadPackage{

	@Override
	public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable {

		if(!lpparam.packageName.equals(Common.PACKAGENAME))return;
		
		for(Class<?> clazz : Common.hookList) {
			AbstractHook hook = (AbstractHook) clazz.newInstance();
			hook.setClassLoader(lpparam.classLoader);
			hook.doHook();
			
			File logDir = new File(Common.LOGPATH);
			if(!logDir.exists()) {
				logDir.mkdirs();
			}
			
			TrackerLoger.log("", "-------------------[STARTUP]-------------------", clazz.getName(), false);
		}
	}
	
}
